<?php 
namespace app\zylib\model;
use think\Model;
use think\Db;
/**
 * 
 */
class ApiZyBaseModel extends Model
{
	/**
	 * 检查请求密匙是否正确
	 */
	public function authorizationCheck($aid,$key){
		$res=Db::name('company')->where('aid','==='.$aid)->find();
		if(empty($res)){
			return zy_json(false,'请求被拒绝：无效的请求标识',null,52);
		}
		if($res['status']==0){
			return zy_json(false,'请求被拒绝：账户已被禁用',null,55);
		}
		$realyKey=md5(md5($res['id'].$res['create_time']).$res['create_time']);
		if( md5($key.$res['create_time']) != $realyKey ){
			return zy_json(false,'请求被拒绝：验证未通过',null,53);
		}
		if($res['period']<time()){
			return zy_json(false,'请求被拒绝：账户到期',null,54);
		}
		return true;
	}
}